package main

import (
	"time"
	"fmt"
	"sync"
)


func main(){

	var sg  sync.WaitGroup

	for i:=0;i<10;i++{
		sg.Add(1)
		go func(id int){
			defer sg.Done()
			time.Sleep(time.Second)
			println("goroutine",id,"done")
		}(i)
	}
	fmt.Println("main...")
	sg.Wait()
	fmt.Println("main done!")
}